import java.util.Random;
import java.util.Scanner;//包

public class Main {
    public static void main(String[] args) {
        //辗转相除法求最大公约数
        int a = 20;
        int b = 40;
        int c = a % b;
        while(c != 0) {
            a = b;
            b = c;
            c = a % b;
        }
        System.out.println(b);
    }

    public static void main5(String[] args) {
        System.out.println("请输入一个整数：");
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        //00000000 00000000 00000000 00000110    6
        //偶数位：
        //00000000 00000010    2
        //奇数位：
        //00000000 00000001    1
        //0~31

        //奇数
        System.out.println("奇数是：");
        for (int i = 31; i >= 1 ; i-=2) {
            System.out.print(((n >> i) & 1) + " " );
        }

        System.out.println();

        //偶数
        System.out.println("偶数是：");
        for (int i = 30; i >= 0; i-=2) {
            System.out.print(((n >> i) & 1) + " " );
        }
    }
    public static void main4(String[] args) {
        //模拟登陆
        int password = 123456;
        Scanner n = new Scanner(System.in);
        int count = 3;
        System.out.println("还有" + count + "次机会");
        while(count != 0) {
            int number = n.nextInt();
            if(number != password) {
                count--;
                System.out.println("密码错误，还有" + count + "次机会");
            } else {
                System.out.println("密码正确");
                break;
            }
        }
        n.close();
    }


    //求每一位数字
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int tmp = 0;
        while (num != 0) {
            tmp = num % 10;
            System.out.println(tmp);
            num /= 10;
        }
        scanner.close();
    }



    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            for(int i = 1; i <= n; i++) {
                for(int j = 1; j <= n; j++) {
                    if((i == j) || ((i + j) == n + 1)) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }
        }
    }

    public static void main1(String[] args) {
        //猜数字游戏
        Scanner scanner = new Scanner(System.in);
        //生成1~100的随机数
        Random random = new Random();
        int guess = random.nextInt(101);//生成[0~100)的随机数
        while(true) {
            System.out.println("请输入你要猜的数字：");
            int num = scanner.nextInt();
            if(num < guess) {
                System.out.println("猜小了");
            } else if(num > guess) {
                System.out.println("猜大了");
            } else {
                System.out.println("恭喜你，猜对了");
                break;
            }
        }
        scanner.close();


        /*//循环输入
        Scanner flag = new Scanner(System.in);
        while(flag.hasNextInt()) {
            int num = flag.nextInt();
            System.out.println(num);
        }*/

        //输入
        /*Scanner scan = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = scan.nextLine();//读入一行
        System.out.println("姓名："+ name);*/

        /*Scanner scan = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = scan.next();//遇到空格结束
        System.out.println("姓名："+ name);

        System.out.println("请输入年龄：");
        int age = scan.nextInt();
        System.out.println("年龄："+ age);

        System.out.println("请输入薪水：");
        float salary = scan.nextFloat();
        System.out.println("薪水："+ salary);
        scan.close();//不用了要关上*/


        /*double sign = 1.0;//符号
        double sum = 0.0;
        //分母
        for (int m = 1; m <= 100; m++) {
            sum += (1.0/m) * (sign);
            sign *= (-1);
        }
        System.out.println(sum);*/


        /*int count = 0;
        for (int i = 1; i <= 100; i++) {
            if(i % 10 == 9) {
                count++;
            }
            if(i / 10 == 9) {
                count++;
            }
        }
        System.out.println(count);*/


        //求100~200之间既能被3整除的数字，又能被4整除的数字   要求：使用continue
        /*int num = 100;
        while(num <= 200) {
            if((num % 3 != 0) || (num % 4 != 0)) {
                num++;
                continue;
            }
            System.out.println(num);
            num++;
        }*/
    }
}